<template>
  <view class="bottombox">
    <view class="middlebox" @tap="saoyisao">
      <image
        class="workbench-item__icon_uni"
        :src="`../../static/saoma.svg`"
        mode=""
      ></image>
    </view>
    <view
      class="tableft"
      :class="type == 'userhome' ? 'activebtn' : ''"
      @tap="toHome"
    >
      <i class="iconfont icon-biaoqianlan_shouye"></i>
      <view>首页</view>
    </view>
    <view
      class="tabright"
      :class="type == 'usermy' ? 'activebtn' : ''"
      @tap="toMy"
    >
      <i class="iconfont icon-wodedamaijihuo"></i>
      <view>我的</view>
    </view>
  </view>
</template>

<script>
import { router } from "@/router/index.js";
export default {
  props: ["type"],
  data() {
    return {};
  },

  methods: {
    // 首页
    toHome() {
      uni.reLaunch({
        url: "/pages/home/index",
      });
    },
    // 我的
    toMy() {
      uni.reLaunch({
        url: "/pages/mine/mine",
      });
    },
    saoyisao() {
      // router.toPage({
      //   path: "/pages/znxj/xjrw/smrw",
      //   params: {
      //     id: 628,
      //   },
      // });
      // return;
      // 只允许通过相机扫码
      uni.scanCode({
        success: function (res) {
          let data = "";
          try {
            data = JSON.parse(res.result);
          } catch (e) {
            data = res.result;
          }
          if (data instanceof Object) {
            if (data.type == "双重预防") {
              router.toPage({
                path: "/pages/yhpc/pcjh/pcrwsm",
                params: {
                  id: data.id,
                },
              });
            } else if (data.type == "巡检") {
              router.toPage({
                path: "/pages/znxj/xjrw/smrw",
                params: {
                  id: data.id,
                },
              });
            } else {
              uni.showToast({
                title: "未识别二维码",
              });
            }
          } else {
            uni.showToast({
              title: "未识别二维码",
            });
          }
        },
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.bottombox {
  flex: none;
  height: 100upx;
  background: #fff;
  display: flex;
  position: fixed;
  width: 100vw;
  bottom: 0;
  .tableft,
  .tabright {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-top: 1rpx solid rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
    > i {
      font-size: 48rpx;
      color: #bfbdbe;
    }

    > view {
      color: #939194;
      font-size: 40rpx;
      font-weight: 500;
      line-height: 1em;
      margin-top: 6rpx;
    }
  }

  .activebtn {
    > i {
      color: #384ef3;
    }

    > view {
      color: #384ef3;
    }
  }

  .middlebox {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translate(-50%, -36rpx);
    width: 120rpx;
    height: 120rpx;
    border-radius: 50%;
    background: #384ef3;
    overflow: hidden;
    // background: linear-gradient(180deg, #2276e4 0%, #294fbf 100%);
    box-shadow: 0px 6px 12px 2px rgba(0, 0, 0, 0.16);
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    > image {
      width: 130rpx;
      height: 130rpx;
    }
    > i {
      font-size: 73rpx;
      color: #fff;
    }
  }
}
</style>
